/**
 * Created by Administrator on 2017/4/26.
 */
function shouhuo(ordercode) {
    if (confirm("确定收货？")) {
        $w.httpRequest({
            url: ctx + "/we/WeReceiptGoods",
            data: {"ordercode": ordercode},
            ok: function () {
                window.location.reload();
            }
        })
    }

}

function cancelorder(ordercode) {
    if (confirm("确定取消订单？")) {
        $w.httpRequest({
            url: apiroot + "/we/WeCancelorder",
            data: {"ordercode": ordercode},
            ok: function (ret) {
                window.location.reload();
            }
        })
    }
}

function buyagain(ordercode) {
    $w.httpRequest({
        url: apiroot + "/order/generateorder2",
        data: {"data": ordercode, "type": "orderbuyagain"},
        ok: function (ret) {
            var ordercode = ret.Data;
            window.location.href = ctx + "/we/order/" + ordercode;
        }, fail: function (ret) {
            if (ret.MsgCode == '101') {
                var h = "以下商品库存不足：";
                var list = window.eval(ret.MsgDesc);
                for (var i = 0; i < list.length; i++) {
                    h += "\r\n" + (i + 1) + "、" + list[i].productname + (list[i].attrname || '');
                }
                alert(h);
            } else if (ret.MsgCode == '102') {
                var h = "以下商品已下架：";
                var list = window.eval(ret.MsgDesc);
                for (var i = 0; i < list.length; i++) {
                    h += "\r\n" + (i + 1) + "、" + list[i].productname + (list[i].attrname || '');
                }
                alert(h);
            } else if (ret.MsgCode == '103') {
                var h = "以下商品已不在您的可购范围：";
                var list = window.eval(ret.MsgDesc);
                for (var i = 0; i < list.length; i++) {
                    h += "\r\n" + (i + 1) + "、" + list[i].productname + (list[i].attrname || '');
                }
                alert(h);
            } else alert(ret.MsgDesc);
            return false;
        }
    })
}
